package com.game.core.resp;

import com.alibaba.fastjson.JSONArray;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

@Data
@Builder
@NoArgsConstructor
public class ApiResult extends LinkedHashMap<String, Object> {
    private static final long serialVersionUID = 1L;

    public ApiResult add(String key, Object value) {
        this.put(key, value);
        return this;
    }

    public ApiResult addAll(Map<String, Object> map) {
        this.putAll(map);
        return this;
    }

    @Override
    public String toString() {
        JSONArray jArray = new JSONArray();
        jArray.add(this);
        return jArray.toJSONString();
    }
}
